/*
 * @(#)BrownPalette.java	0.1 2002-09-12
 * 
 * Copyleft 2002 Wonseok Shin, Taeksoo Jung
 * Anyone can get benefits from this.
 */
package cs348a.color;

/**
 * A <code>BrownPalette</code> defines a brown palette.
 * 
 * @version	0.1
 * @author		Wonseok Shin, Taeksoo Jung
 * @since		0.1
 */
public final class BrownPalette extends BasicPalette {		
	/** Singleton instance */
	public static final BrownPalette INSTANCE = getInstance();
		
	/**
	 * Constructor for <code>BrownPalette</code>.
	 * 
	 * @param reds array of red components
	 * @param greens array of green components
	 * @param blues array of blue components
	 */
	private BrownPalette(byte[] reds, byte[] greens, byte[] blues) {
		super("Brown", reds, greens, blues);
	}
	
	/**
	 * Returns the singleton instance.
	 * 
	 * @return the singleton instance
	 */
	private static BrownPalette getInstance() {
		// Creates arrays of components.
		byte[] reds = new byte[SIZE];
		byte[] greens = new byte[SIZE];
		byte[] blues = new byte[SIZE];
		
		// Constructs the components.
		for (int i = 0; i < SIZE; i++) {
			double p = (double) i / SIZE;

			// Sets the red component.
			double f = (p) * SIZE;
			reds[i] = cutOff(f);
			
			// Sets the green component.
			f = (p * 3.0 / 2.0 - 1.0 / 2.0) * SIZE;
			greens[i] = cutOff(f);
			
			// Sets the blue component.
			f = (p * 3.0 - 2.0) * SIZE;
			blues[i] = cutOff(f);
		}
		
		return new BrownPalette(reds, greens, blues);
	}
}
